package cn.cloud.jianghai.orderapi.feign;

import cn.cloud.jianghai.jianghaicommon.entity.R;
import cn.cloud.jianghai.orderapi.entity.OrderDto;
import cn.cloud.jianghai.orderapi.feign.fallback.OrderFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author Jiang.h
 * created 2022/5/21 17:35
 */
@FeignClient(value = "jianghai-order", fallback = OrderFallback.class)
public interface OrderApi {


    String API_PREFIX = "/v1/api/order/";

    /**
     * 查询订单列表 根据用户id列表
     * @Date 2022/5/22 17:59
     * @Author Jiang.h
     * @return cn.cloud.jianghai.orderapi.entity.R<java.util.List<cn.cloud.jianghai.orderapi.entity.OrderDto>>
     **/
    @PostMapping(API_PREFIX + "findOrderList")
    R<List<OrderDto>> findOrderList(@RequestBody List<Long> userIdList);

    /**
     *  创建订单
     * @param orderDto 订单信息
     * @Date 2022/5/22 18:05
     * @Author Jiang.h
     * @return cn.cloud.jianghai.orderapi.entity.R<java.lang.Boolean>
     **/
    @PostMapping(API_PREFIX + "/insertOrder")
    R<Boolean> insertOrder(@RequestBody OrderDto orderDto);

    @GetMapping("/testHystrix")
    R<List<OrderDto>> testHystrix(@RequestParam("id") Long id);
}
